<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sx" uri="/struts-dojo-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<sx:head />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>儿童版管理</title>
<script src="js/jquery-1.7.1.min.js" type="text/javascript"></script>
<link type="text/css"
	href="css/ui-lightness/jquery-ui-1.8.16.custom.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-ui-1.8.16.custom.min.js"></script>
<link href="css/sytle.css" rel="stylesheet" type="text/css" />
<script>
	var menu_2_click = new Boolean("true");
	var menu_3_click = new Boolean("true");
	$(function() {
		$("#tabs").tabs();
		$("#edituser_dialog").dialog({
			autoOpen : false,
			show : "blind",
			hide : "explode"
		});
		$("#menu_2").click(function() {
			if (menu_2_click) {
				menu_2_click = false;
				getTaskList();
			}
		});
		$("#menu_3").click(function() {
			if (menu_3_click) {
				menu_3_click = false;
				getAnnouncementList();
			}
		});
		<s:if test="#session.USER_TYPE=='admin'">
		getUserList();

		$("#addTask_dialog").dialog({
			autoOpen : false,
			show : "blind",
			hide : "explode"
		});
		$("#addTask").click(function() {
			$("#addTask_dialog").dialog("open");
		});
		$("#editAnnouncementList_dialog").dialog({
			autoOpen : false,
			show : "blind",
			hide : "explode"
		});
		</s:if>
		<s:else>
		getUser(<s:property value="#session.USER_ID"/>);
		$("#userInfoEdit").click(function() {
			editUser(<s:property value="#session.USER_ID"/>);
		});
		</s:else>

	});
	<s:if test="#session.USER_TYPE=='admin'">

	function getUserList() {
		var url = "getUserList";
		$.getJSON(url, null, function callback(data) {
			$.each(data, function(i, n) {
				var row = $("#userlist").clone();
				row.find("#userId").text(n.userid);
				row.find("#userName").text(n.name);
				if (n.sex) {
					row.find("#sex").text("男");
				} else {
					row.find("#sex").text("女");
				}
				row.find("#registerDate").text(n.createDate);
				row.find("#group").text(n.group);
				row.find("#edit").html(
						"<a href='#' onClick='editUser(" + n.userid
								+ ")'>编辑</a>");
				$("#users").append(row);
			});
		});
	}
	function editAnnouncement(type) {
		$("#editAnnouncement_action").val(type);
		$("#editAnnouncementList_dialog").dialog("open");
	}
	function getAnnouncement(the_id) {
		var url = "getAnnouncement";

		$.getJSON(url, {
			id : the_id
		}, function callback(data) {
			$("#editAnnouncement_action").val("edit");
			$("#editAnnouncement_date").val(data.date);
			$("#editAnnouncement_content").val(data.content);
			$("#editAnnouncementList_dialog").dialog("open");
		});
	}
	</s:if>
	function getUser(id) {
		var url = "getUser";
		$.getJSON(url, {
			userid : id
		}, function callback(data) {
			$("#userInfo_name").text(data.name);
			$("#userInfo_group").text(data.group);
			$("#userInfo_type").text(data.type);
			$("#userInfo_graduated").text(data.graduated);
			$("#userInfo_address").text(data.address);
			$("#userInfo_mobile").text(data.mobile);
			$("#userInfo_telephone").text(data.telephone);
			$("#userInfo_email").text(data.email);
			$("#userInfo_workingOrgans").text(data.workingOrgans);
			$("#userInfo_workPosition").text(data.workPosition);
			$("#userInfo_artisticSkills").text(data.artisticSkills);
		});
	}
	function editUser(id) {
		var url = "getUser";
		$.getJSON(url, {
			userid : id
		}, function callback(data) {
			$("#user_userid").val(data.userid);
			$("#user_name").val(data.name);
			$("#user_group").val(data.group);
			$("#user_type").val(data.type);
			$("#user_graduated").val(data.graduated);
			$("#user_address").val(data.address);
			$("#user_mobile").val(data.mobile);
			$("#user_telephone").val(data.telephone);
			$("#user_email").val(data.email);
			$("#user_workingOrgans").val(data.workingOrgans);
			$("#user_workPosition").val(data.workPosition);
			$("#user_artisticSkills").val(data.artisticSkills);
			$("#edituser_dialog").dialog("open");
		});
	}
	function getTaskList() {
		var url = "getTaskList";

		$.getJSON(url, null, function callback(data) {
			$.each(data, function(i, n) {
				var row = $("#taskList").clone();
				row.find("#taskList_id").text(n.id);
				row.find("#taskList_group").text(n.group);
				row.find("#taskList_datetime").text(n.datetime);
				row.find("#taskList_work").text(n.work);
				row.find("#taskList_workers").text(n.workers);
				row.find("#taskList_info").text(n.info);
				row.find("#taskList_commont").text(n.commont);
				row.find("#taskList_state").text(n.state);
				<s:if test="#session.USER_TYPE=='admin'">
				row.find("#taskList_edit").html(
						"<a href='editTask?userid=" + n.userid + "'>编辑</a>");
				</s:if>
				$("#tasks").append(row);
			});
		});
	}
	function getAnnouncementList() {
		var url = "getAnnouncementList";

		$.getJSON(url, null, function callback(data) {
			$.each(data, function(i, n) {
				var row = $("#announcement").clone();
				row.find("#announcement_id").text(n.id);
				row.find("#announcement_group").text(n.group);
				row.find("#announcement_date").text(n.date);
				row.find("#announcement_content").text(n.content);
				row.find("#announcement_user").text(n.user);
				<s:if test="#session.USER_TYPE=='admin'">
				row.find("#announcement_eidt").html(
						"<a href=\"#\" onClick=\"getAnnouncement('" + n.id
								+ "')\">修改</a>");
				</s:if>
				$("#announcementList").append(row);
			});
		});
	}
</script>
</head>

<body>

	<div class="container">

		<div id="edituser_dialog">
			<s:i18n name="globalMessage">
				<s:form id="editUserForm" action="editUser">
					<s:hidden id="user_userid" name="user.userid"></s:hidden>
					<s:textfield id="user_name" name="user.name" key="user.name"></s:textfield>
					<sx:datetimepicker id="user_birthday" name="user.birthday"
						key="user.birthday" displayFormat="yyyy-MM-dd" />
					<s:if test="#session.USER_GROUP=='admin'">
						<s:select id="user_group" name="user.group"
							list="#{'admin':'管理组','children':'儿童班','choir':'唱诗班','liaison':'外联部','biblestudy':'查经班',
							'services':'服务组','user':'用户组'}"
							listKey='key' listValue="value" key="user.group"></s:select>
						<s:select id="user_type" name="user.type" key="user.type"
							list="#{'user':'用户 ','admin':'管理员'}" listKey="key"
							listValue="value"></s:select>
					</s:if>

					<s:textfield id="user_graduated" name="user.graduated"
						key="user.graduated"></s:textfield>
					<s:textfield id="user_address" name="user.address"
						key="user.address"></s:textfield>
					<s:textfield id="user_mobile" name="user.mobile" key="user.mobile"></s:textfield>
					<s:textfield id="user_telephone" name="user.telephone"
						key="user.telephone"></s:textfield>
					<s:textfield id="user_email" name="user.email" key="user.email"></s:textfield>
					<s:textfield id="user_workingOrgans" name="user.workingOrgans"
						key="user.workingOrgans"></s:textfield>
					<s:textfield id="user_workPosition" name="user.workPosition"
						key="user.workPosition"></s:textfield>
					<s:textfield id="user_artisticSkills" name="user.artisticSkills"
						key="user.artisticSkills"></s:textfield>
					<s:submit key="user.submit"></s:submit>
				</s:form>
			</s:i18n>
		</div>
		<div id="tabs">
			<ul>
				<s:if test="#session.USER_TYPE=='admin'">
					<li><a id="menu_1" href="#tabs-1">用戶管理</a></li>
					<li><a id="menu_2" href="#tabs-2">计划管理</a></li>
					<li><a id="menu_3" href="#tabs-3">公告管理</a></li>
				</s:if>
				<s:else>
					<li><a id="menu_1" href="#tabs-1">个人信息</a></li>
					<li><a id="menu_2" href="#tabs-2">部门计划</a></li>
					<li><a id="menu_3" href="#tabs-3">部门公告</a></li>
				</s:else>
				<li><a id="menu_4" href="#tabs-4">儿童信息</a></li>
				<li><a id="menu_5" href="#tabs-5">课程表</a></li>
			</ul>
			<div id="tabs-1">
				<s:if test="#session.USER_TYPE=='admin'">
					<div id="editAnnouncementList_dialog">
						<s:i18n name="globalMessage">
							<s:form id="editAnnouncementForm" action="editAnnouncement">
								<s:hidden id="editAnnouncement_id" name="announcement.id"></s:hidden>
								<s:hidden id="editAnnouncement_action" name="action"></s:hidden>
								<s:if test="#session.USER_GROUP=='admin'">
									<s:select id="editAnnouncement_group" name="announcement.group"
										list="#{'admin':'管理组','children':'儿童班','choir':'唱诗班','liaison':'外联部','biblestudy':'查经班',
							'services':'服务组','user':'用户组'}"
										listKey='key' listValue="value" key="announcement.group"></s:select>
								</s:if>
								<sx:datetimepicker id="editAnnouncement_date"
									name="announcement.date" key="announcement.date"
									displayFormat="yyyy-MM-dd" />
								<s:textarea id="editAnnouncement_content"
									name="announcement.content" key="announcement.content"></s:textarea>
								<s:submit key="announcement.submit"></s:submit>
							</s:form>
						</s:i18n>
					</div>
					<h1>用戶管理</h1>
					<table id="users" border="1" cellspacing="0"
						style="border-collapse: collapse">
						<tr>
							<th>用户ID</th>
							<th>用户名</th>
							<th>性别</th>
							<th>注册时间</th>
							<th>用户组</th>
							<th>功能</th>
						</tr>
						<tr id="userlist">
							<td id="userId"></td>
							<td id="userName"></td>
							<td id="sex"></td>
							<td id="registerDate"></td>
							<td id="group"></td>
							<td id="edit"></td>
						</tr>
					</table>
				</s:if>
				<s:else>
					<h1>个人信息</h1>
					<div id="userInfo">
						<s:i18n name="globalMessage">
							<a href="#" id="userInfoEdit"><s:text name="user.edit" /></a>
							<p></p>
							<s:text name="user.name"></s:text>
							<b><div id="userInfo_name"></div></b>
							<s:text name="user.birthday" />
							<b><div id="userInfo_birthday"></div></b>
							<s:text name="user.group"></s:text>
							<b><div id="userInfo_group"></div></b>
							<s:text name="user.type"></s:text>
							<b><div id="userInfo_type"></div></b>
							<s:text name="user.graduated"></s:text>
							<b><div id="userInfo_graduated"></div></b>
							<s:text name="user.address"></s:text>
							<b><div id="userInfo_address"></div></b>
							<s:text name="user.mobile"></s:text>
							<b><div id="userInfo_mobile"></div></b>
							<s:text name="user.telephone"></s:text>
							<b><div id="userInfo_telephone"></div></b>
							<s:text name="user.email"></s:text>
							<b><div id="userInfo_email"></div></b>
							<s:text name="user.workingOrgans"></s:text>
							<b><div id="userInfo_workingOrgans"></div></b>
							<s:text name="user.workPosition"></s:text>
							<b><div id="userInfo_workPosition"></div></b>
							<s:text name="user.artisticSkills"></s:text>
							<b><div id="userInfo_artisticSkills"></div></b>
						</s:i18n>
					</div>
				</s:else>
			</div>
			<div id="tabs-2">
				<h1>任务列表</h1>
				<s:if test="#session.USER_TYPE=='admin'">
					<div id="addTask_dialog">
						<s:i18n name="globalMessage">
							<s:text name="task.add"></s:text>
							<s:form action="addTask">
								<s:if test="#session.USER_GROUP=='admin'">
									<s:select id="task_group" name="tasklist.group"
										list="#{'admin':'管理组','children':'儿童班','choir':'唱诗班','liaison':'外联部','biblestudy':'查经班',
							'services':'服务组'}"
										listKey='key' listValue="value" key="task.group"></s:select>
								</s:if>
								<sx:datetimepicker name="tasklist.datetime" key="task.datetime"
									displayFormat="yyyy-MM-dd" />
								<s:textfield name="tasklist.work" key="task.work"></s:textfield>
								<s:textfield name="tasklist.workers" key="task.workers"></s:textfield>
								<s:textfield name="tasklist.info" key="task.info"></s:textfield>
								<s:textfield name="tasklist.commont" key="task.commont"></s:textfield>
								<s:submit key="task.submit"></s:submit>
							</s:form>
						</s:i18n>
					</div>
					<h2>
						<a href="#" id="addTask">添加任务</a>
					</h2>
				</s:if>
				<table id="tasks" border="1" cellspacing="0"
					style="border-collapse: collapse">
					<tr>
						<th>任务ID</th>
						<th>部门</th>
						<th>时间</th>
						<th>事由</th>
						<th>人员</th>
						<th>说明</th>
						<th>备注</th>
						<th>状态</th>
						<s:if test="#session.USER_TYPE=='admin'">
							<th>修改</th>
						</s:if>
					</tr>
					<tr id="taskList">
						<td id="taskList_id"></td>
						<td id="taskList_group"></td>
						<td id="taskList_datetime"></td>
						<td id="taskList_work"></td>
						<td id="taskList_workers"></td>
						<td id="taskList_info"></td>
						<td id="taskList_commont"></td>
						<td id="taskList_state"></td>
						<s:if test="#session.USER_TYPE=='admin'">
							<td id="taskList_eidt"></td>
						</s:if>
					</tr>
				</table>
			</div>
			<div id="tabs-3">
				<s:if test="#session.USER_TYPE=='admin'">
					<h1>
						<a href="#" onclick="editAnnouncement('add')">添加</a>
					</h1>
				</s:if>

				<table id="announcementList" border="1" cellspacing="0"
					style="border-collapse: collapse">
					<tr>
						<th>公告ID</th>
						<th>部门</th>
						<th>时间</th>
						<th>内容</th>
						<th>发布者</th>
						<s:if test="#session.USER_TYPE=='admin'">
							<th>修改</th>
						</s:if>
					</tr>
					<tr id="announcement">
						<td id="announcement_id"></td>
						<td id="announcement_group"></td>
						<td id="announcement_date"></td>
						<td id="announcement_content"></td>
						<td id="announcement_user"></td>
						<s:if test="#session.USER_TYPE=='admin'">
							<td id="announcement_eidt"></td>
						</s:if>
					</tr>
				</table>
			</div>
			<div id="tabs-4">
				<p>&nbsp;</p>
				<h1>儿童信息</h1>
				<p>&nbsp;</p>
				<table id="announcementList" border="1" cellspacing="0"
					style="border-collapse: collapse">
					<tr>
						<th>ID</th>
						<th>姓名</th>
						<th>性别</th>
						<th>年龄</th>
					</tr>
					<tr id="announcement">
						<td id="announcement_id"></td>
						<td id="announcement_group"></td>
						<td id="announcement_date"></td>
						<td id="announcement_content"></td>
						<td id="announcement_user"></td>
					</tr>
				</table>
			</div>
			<div id="tabs-5">
				<p>&nbsp;</p>
				<h1>课程表</h1>
				<p>&nbsp;</p>
				<table id="announcementList" border="1" cellspacing="0"
					style="border-collapse: collapse">
					<tr>
						<th>ID</th>
						<th>姓名</th>
						<th>性别</th>
						<th>年龄</th>
					</tr>
					<tr id="announcement">
						<td id="announcement_id"></td>
						<td id="announcement_group"></td>
						<td id="announcement_date"></td>
						<td id="announcement_content"></td>
						<td id="announcement_user"></td>
					</tr>
				</table>
			</div>
		</div>

	</div>

</body>
</html>
